get XScrollBox("baker","Choose one of these:",card field "scroller","Help")
go this card
if it is "Help" then
answer "You pushed the 'Help' button."
else if it is "cancel" then
answer "You pushed the 'Cancel' button."
else if it is empty then
answer "You did not select anything."
else
answer "Your choice was: " & it
end if
end mouseUp
-- part 5 (field)
-- low flags: 01
-- high flags: 2007
-- rect: left=17 top=31 right=286 bottom=382
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Documentation
-- part 7 (field)
-- low flags: 81
-- high flags: 0007
-- rect: left=18 top=31 right=290 bottom=489
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Source1
-- part 11 (field)
-- low flags: 81
-- high flags: 0007
-- rect: left=18 top=31 right=290 bottom=489
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Source2
-- part 12 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=289 top=298 right=320 bottom=458
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show C Source: part 1
----- HyperTalk script -----
on mouseUp
if the short name of me is "Show C Source: part 1" then
set the visible of card field "source1" to true
set the visible of card field "source2" to false
set the name of me to "Show C Source: part 2"
else if the short name of me is "Show C Source: part 2" then
set the visible of card field "source2" to true
set the visible of card field "source1" to false
set the name of me to "Hide C Source"
else
set the visible of card field "source2" to false
set the visible of card field "source1" to false
set the name of me to "Show C Source: part 1"
end if
end mouseUp
-- part contents for card part 2
----- text -----
able
baker
charlie
dog
ernest
fox
gamma
horse
ice cream
jumping jack flash
knockwurst
liver
monkey
no way, jose
occularity
penelope
qwerty
rapscallion
salubrious
twinkle toes
underwhelmed
vermin
wascally wabbit
yokel
zenzational
-- part contents for card part 5
----- text -----
XScrollBox version 2.4
Roger Brown
XScrollBox is a HyperCard XFCN that creates a scrolling selection dialog box from any multi-lined container. Each line of the container is made into a selection line in the dialog. Only one line can be selected.
The return value has two items: the number of the selection and the text of the selection. These are separated by commas as in normal HyperCard format.
Selection can be made by :
1. double-clicking on a line.
2. single-clicking on a line, then pressing the OK button.
3. single-clicking on a line, then pressing the Return key.
4. typing the first letter(s) of a selection, then doing 1,2, or 3.
(Note: type selection assumes that the lines are ordered
alphabetically)
5. scrolling with up and down arrow keys, then doing 1,2 or 3.
If the Cancel button is pressed, the string "Cancel" is returned.
It requires that the DITL and DLOG resources (1345) packaged
with it are in the stack.
The dialog is centered on the screen and sized to hold the width of the longest line and/or the prompt line, whichever is widest. It will not overrun the width of a Mac+ screen.
INVOKING XScrollBox
get XScrollBox(first,prompt,container,userButton)
where first is a default selection in the list - either a number or
a text string (0 if none).
prompt is a string to prompt the user. This appears at the
top of the dialog box.
container is any hypercard container (field, variable),
presumed to be multi-lined.
UserButton is the name for an optional author specified
button. If this button is pressed, its name is
returned further processing by the script.
EXAMPLE
ex. get XScrollBox(1,"Choose:",card field 1,"Help")
if OK is pressed, returns : 1,text of line 1 of card field 1
REVISION HISTORY
1.1 center dialog box on any size screen
1.2 - add selection scrolling by typing and by cursor keys
1.3 - add text of chosen item to return value
1.4 - 3/2/88 add optional user button
1.6 - 5/12/89 fixed problem with selecting the first item the
first time when type-selecting. Fixed problem where typing
an item exactly selects the one after it.
1.7 - 5/15/89 made it compile under LSC 3.0.
2.0 - 9/9/89 SuperCard compatible, fixed bugs in typing-selection,
and userButton string handling. First item is selected if there
is no default and the user presses a cursor arrow key. One
source for all 3 versions, control version with compiler
variables. Compiles under THINK C Γäó 4.0.
2.1 - 2/21/90 Push of cancel button now returns "Cancel" string.
Fixed some bugs in allocatin and use of return handle.